using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;

namespace DbView
{
	/// <summary>
	/// Summary description for SimpleRegex.
	/// </summary>
	public class SimpleRegex : System.Text.RegularExpressions.Regex
	{
		Match current;

		public SimpleRegex(String source)
			: base(source, RegexOptions.IgnoreCase)
		{
		}

		public String this[int index]
		{
			get
			{
				return current.Groups[index].Value;
			}
		}

		public bool MatchTarget(String target)
		{
			this.current = this.Match(target);
			// if match
			return current.Success;
		}

		public int[,] GetMatches(String target)
		{
			MatchCollection hits = this.Matches(target);
			int [,] result = new int[hits.Count, 2];
			for (int idx = 0; idx < hits.Count; ++idx)
			{
				result[idx, 0] = hits[idx].Index;
				result[idx, 1] = hits[idx].Length;
			}
			return result;
		}
	}
}
